<?php
class info_address extends Model{
	public static function getTableName(){
		return 'info_address';
	}

	public function set($object){
		$this->episode_id = !isset($object->episode_id) ? '0' : $object->episode_id;
		$this->venue_name_chinese = !isset($object->venue_name_chinese) ? '' : trim($object->venue_name_chinese);
		$this->venue_name_english = !isset($object->venue_name_english) ? '' : trim($object->venue_name_english);
		$this->venue_category = !isset($object->venue_category) ? '0' : $object->venue_category;
		$this->street_line_1 = !isset($object->street_line_1) ? '' : trim($object->street_line_1);
		$this->street_line_2 = !isset($object->street_line_2) ? '' : trim($object->street_line_2);
		$this->city = !isset($object->city) ? '' : trim($object->city);
		$this->province_state_prefecture = !isset($object->province_state_prefecture) ? '0' : $object->province_state_prefecture;
		$this->country = !isset($object->country) ? '0' : $object->country;
		$this->phone_number = !isset($object->phone_number) ? '' : trim($object->phone_number);
		$this->fax_number = !isset($object->fax_number) ? '' : trim($object->fax_number);
		$this->url = !isset($object->url) ? '' : trim($object->url);
		$this->email = !isset($object->email) ? '' : trim($object->email);
		$this->contact_person = !isset($object->contact_person) ? '' : $object->contact_person;
		$this->useful_information = !isset($object->useful_information) ? '' : $object->useful_information;
        $this->publish_datetime = !isset($object->publish_datetime) ? '' : $object->publish_datetime; 
        $this->expire_datetime = !isset($object->expire_datetime) ? '' : $object->expire_datetime; 
		$this->status = !isset($object->status) ? '0' : $object->status;
		$this->created_by = !isset($object->created_by) ? '' : $object->created_by;
		$this->created_at = !isset($object->created_at) ? '' : $object->created_at;
		$this->modified_by = !isset($object->modified_by) ? '' : $object->modified_by;
		$this->modified_at = !isset($object->modified_at) ? '' : $object->modified_at;

		$this->description = !isset($object->description) ? '' : $object->description;
	}

	/*
	 * by donald
	 */
	public function add_change_log()
	{
		$field['type'] = $this->getTableName();
		$field['keys'] = array('id' => $this->id);
		$field['is_active'] = 1;
		$field['programme_id'] = 0;
		$field['episode_id'] = $this->episode_id;
		$field['is_publish'] = 0;

		change_log::updateOne($field);
	}

	/*
	 * by donald
	 */
	public function delete_change_log()
	{
		$type = $this->getTableName();
		$keys = array('id' => $this->id);
		$is_publish = 0;

		change_log::delTypeAndKeysLog($type, $keys, $is_publish);
	}
}
?>  
